import java.util.*;

public class Inventory {
	private ArrayList<AvailableItem> items;
	
	public Inventory () {
	    items = new ArrayList<AvailableItem> ();
	}
	public AvailableItem getAvailableItem (String id) {
        int index = findProduct (id);
        if (index == -1) {
            return null;
        } else {
            return items.get (index);
        }
	}
	public void addProduct (String id, double price, String desc, int quantity) {
        int index = findProduct (id);
        if (index == -1) {
            items.add (new AvailableItem (id, price, desc, quantity));
        } else {
            System.out.println ("Item of ID \"" + id + "\" already exists.");
        }
	}
	public void removeProduct (String id) {
	    int index = findProduct (id);
	    if (index != -1) {
	        items.remove(index);
	    }
	}
	public int findProduct (String id) {
	    for (int i = 0; i < items.size (); i++) {
	        if (items.get (i).itemID ().equals (id)) {
	            return i;
	        }
	    }
	    return -1;
	}
}
